/*
Package hooks
Gitee WebHook post data struct. it
Copyright © 2022 Roc Sun.
*/

package hooks

import "time"

// GiteeRequest gitee.com webhook requests body struct.
type GiteeRequest interface {
	GiteePushHook | GiteePRHook | GiteeCommentHook
}

type BaseUser struct {
	Id       int    `json:"id"`
	Name     string `json:"name"`
	Email    string `json:"email"`
	Username string `json:"username"`
	UserName string `json:"user_name"`
	Url      string `json:"url"`
}

type Author struct {
	Time time.Time `json:"time"`
	BaseUser
}

type CommonUser struct {
	BaseUser
	Login     string `json:"login"`
	AvatarUrl string `json:"avatar_url"`
	HtmlUrl   string `json:"html_url"`
	Type      string `json:"type"`
	SiteAdmin bool   `json:"site_admin"`
}

type Repo struct {
	Id                int64       `json:"id"`
	Name              string      `json:"name"`
	Path              string      `json:"path"`
	FullName          string      `json:"full_name"`
	Owner             CommonUser  `json:"CommonUser"`
	Private           bool        `json:"private"`
	HtmlUrl           string      `json:"html_url"`
	Url               string      `json:"url"`
	Description       string      `json:"description"`
	Fork              bool        `json:"fork"`
	CreatedAt         time.Time   `json:"created_at"`
	UpdatedAt         time.Time   `json:"updated_at"`
	PushedAt          time.Time   `json:"pushed_at"`
	GitUrl            string      `json:"git_url"`
	SshUrl            string      `json:"ssh_url"`
	CloneUrl          string      `json:"clone_url"`
	SvnUrl            string      `json:"svn_url"`
	GitHttpUrl        string      `json:"git_http_url"`
	GitSshUrl         string      `json:"git_ssh_url"`
	GitSvnUrl         string      `json:"git_svn_url"`
	Homepage          interface{} `json:"homepage"`
	StargazersCount   int         `json:"stargazers_count"`
	WatchersCount     int         `json:"watchers_count"`
	ForksCount        int         `json:"forks_count"`
	Language          string      `json:"language"`
	HasIssues         bool        `json:"has_issues"`
	HasWiki           bool        `json:"has_wiki"`
	HasPages          bool        `json:"has_pages"`
	License           string      `json:"license"`
	OpenIssuesCount   int         `json:"open_issues_count"`
	DefaultBranch     string      `json:"default_branch"`
	Namespace         string      `json:"namespace"`
	NameWithNamespace string      `json:"name_with_namespace"`
	PathWithNamespace string      `json:"path_with_namespace"`
}

type RepoInfo struct {
	Label string     `json:"label"`
	Ref   string     `json:"ref"`
	Sha   string     `json:"sha"`
	User  CommonUser `json:"user"`
	Repo  Repo       `json:"repo"`
}

type PullRequest struct {
	Id                 int           `json:"id"`
	Number             int64         `json:"number"`
	State              string        `json:"state"`
	HtmlUrl            string        `json:"html_url"`
	DiffUrl            string        `json:"diff_url"`
	PatchUrl           string        `json:"patch_url"`
	Title              string        `json:"title"`
	Body               string        `json:"body"`
	Labels             []interface{} `json:"labels"`
	Languages          []interface{} `json:"languages"`
	CreatedAt          time.Time     `json:"created_at"`
	UpdatedAt          time.Time     `json:"updated_at"`
	ClosedAt           interface{}   `json:"closed_at"`
	MergedAt           interface{}   `json:"merged_at"`
	MergeCommitSha     string        `json:"merge_commit_sha"`
	MergeReferenceName string        `json:"merge_reference_name"`
	User               CommonUser    `json:"user"`
	Assignee           interface{}   `json:"assignee"`
	Assignees          CommonUser    `json:"assignees"`
	Tester             interface{}   `json:"tester"`
	Testers            []CommonUser  `json:"testers"`
	NeedTest           bool          `json:"need_test"`
	NeedReview         bool          `json:"need_review"`
	Milestone          interface{}   `json:"milestone"`
	Head               RepoInfo      `json:"head"`
	Base               RepoInfo      `json:"base"`
	Merged             bool          `json:"merged"`
	Mergeable          bool          `json:"mergeable"`
	MergeStatus        string        `json:"merge_status"`
	UpdatedBy          CommonUser    `json:"updated_by"`
	Comments           int           `json:"comments"`
	Commits            int           `json:"commits"`
	Additions          int           `json:"additions"`
	Deletions          int           `json:"deletions"`
	ChangedFiles       int           `json:"changed_files"`
}

//
//type Common struct {
//
//	Repository         Repo        `json:"repository"`
//	Project            Repo        `json:"project"`
//	Sender             CommonUser  `json:"sender"`
//	Enterprise         interface{} `json:"enterprise"`
//	HookName           string      `json:"hook_name"`
//	HookId             int         `json:"hook_id"`
//	HookUrl            string      `json:"hook_url"`
//	Password           string      `json:"password"`
//	Timestamp          time.Time   `json:"timestamp"`
//	Sign               string      `json:"sign"`
//
//
//	Action  string `json:"action"`
//	Repository    Repo        `json:"repository"`
//	Project       Repo        `json:"project"`
//	Author        CommonUser  `json:"author"`
//	Sender        CommonUser  `json:"sender"`
//	Url           string      `json:"url"`
//	Title         string      `json:"title"`
//	Enterprise    interface{} `json:"enterprise"`
//	PullRequest   PullRequest `json:"pull_request"`
//	HookName      string      `json:"hook_name"`
//	HookId        int         `json:"hook_id"`
//	HookUrl       string      `json:"hook_url"`
//	Password      string      `json:"password"`
//	Timestamp     string      `json:"timestamp"`
//	Sign          string      `json:"sign"`
//
//}
